<{include file="../common/iframe_head.tpl"}>
<link href="//unpkg.com/layui@2.11.5/dist/css/layui.css" rel="stylesheet">
<script src="//unpkg.com/layui@2.11.5/dist/layui.js"></script>
<form name='myForm1' id='myForm1' method='post' action='/benchmark/DoDuibiao'>
    <div style='margin:10px;'>
        <table>
            <tr>
                <td><b>题目：</b></td>
                <td><b><{$subject_info.question_num}><{$subject_info.title}></b></td>
            </tr>
            <!--<tr>
                <td>是否申请还分：</td>
                <td><input name='isreturn' type='radio' value='0' <{if $info.isreturn==0}>checked="checked"<{/if}> />否
                    <input type="radio" name="isreturn" value="1" <{if $info.isreturn==1}>checked="checked"<{/if}> />是
                </td>
            </tr>-->
            <tr>
                <td>申诉内容：</td><td><textarea name='suggestion' cols='65' rows='10'><{$info.suggestion}></textarea></td>
            </tr>
            <tr>
                <td>附件：</td>
                <td><br/>
					<button type="button" class="layui-btn layui-btn-danger" id="uploadify">
					  <i class="layui-icon layui-icon-upload"></i> 上传图片
					</button>
					<div class="layui-inline layui-word-aux">
					  (格式不限，总大小限制10M，上传速度与网速有关)
					</div>
                    <!--<input type='file' id="uploadify">(格式不限，总大小限制10M，上传速度与网速有关)-->
                    <{if $info.haveattach==1}>
                    <ul>
                    <{foreach $attachlist as $key => $val}>
                    <li id="attach_<{$val.qba_id}>"><{$val.filename}>&nbsp;&nbsp;&nbsp;&nbsp;<a href="<{$val.url}>" target="_blank">下载</a>&nbsp;<a href="javascript:;" onclick="del(<{$val.qba_id}>);">删除</a></li>
                    <{/foreach}>
                    </ul>
                    <{/if}>
                </td>
            </tr>
            <tr><td colspan='2'><input type='submit' class="button" value='提交'></td></tr>
        </table>
            <input type='hidden' name='subject_id' value='<{$subject_id}>' />
        <input name='nq_id' type='hidden' value='<{$nq_id}>' />
        <input name='qb_id' type='hidden' value='<{$info.qb_id}>' />
    </div>
</form>
    <script>
		//https://layui.dev/docs/2/upload/#render
		layui.use(function(){
		  var upload = layui.upload;
		  var layer = layui.layer;
		  
		  // 渲染
		  upload.render({
		    elem: '#uploadify',
		    url: '/attachment/duibiaoAttach?attach_type=benchmark', // 此处配置你自己的上传接口即可
		    size: 10000, // 限制文件大小，单位 KB
			data:{
				nq_id : <{$nq_id}>,
				subject_id : <{$subject_id}>,
				network_id:<{$network_id}>}
			},
		    done: function(res){
		      layer.msg('上传成功');
		      console.log(res);
		    }
		  });
		});
        var project_email = "超大文件上传请联系项目邮箱<{$project.email}>";
        $(document).ready(function() {     
                var options = {         
                    beforeSubmit:  showRequest,  
                    success:       showResponse,
                    dataType:  'json'
                }
                $('#myForm1').ajaxForm(options); 
                
                
                $('#uploadify').uploadify({
                    'fileSizeLimit' : '10MB',
                    'formData'      : {'nq_id' : <{$nq_id}>, 'subject_id' : <{$subject_id}>,'network_id':<{$network_id}>},
                    'buttonText' : '选择文件',
                    'fileObjName' : 'upfile',   
                    'swf'      : '/js/uploadify.swf',
                    'fileTypeExts' : '*.*',
                    'uploader' : '/attachment/duibiaoAttach?attach_type=benchmark',
                    'onUploadSuccess' : function(file, data, response) {
                        var obj = eval('(' + data + ')');
                        if (obj.state =='SUCCESS'){
                            alert('上传成功');
                        } else {
                            alert(obj.note);
                        }
                    } 
                });   
        });
            function showRequest(formData, jqForm, options) { 
                return true;
            }
            function showResponse(responseText, statusText, xhr, $form)  { 
                alert(responseText.note);
                if (responseText.status==1) {
                    window.parent.thisPage = false;
                    <{if $iframe==1}>
                    window.parent.location.reload();
                    <{else}>
                    window.parent.location.href='<{$referer}>&subject_id=<{$subject_info.subject_id}>';
                    <{/if}>
                }
            }
            //删除附件
            function del(qba_id){
                if (confirm('确定删除此附件！')) {
                    $.getJSON('/benchmark/DelBenchAttach',{qba_id:qba_id},function(res){
                        if (res.status==1) {
                            $('#attach_'+qba_id).remove();
                        }
                        alert(res.note);
                    });
                }
            }
    </script>
<{include file="../common/footer.tpl"}>